﻿using System;
using System.Globalization;
using System.Web.Mvc;

namespace Complaint.Binders
{
    public class DateTimeModelBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var key = bindingContext.ModelName;
            var result = bindingContext.ValueProvider.GetValue(key);
            return result.ConvertTo(typeof(DateTime), CultureInfo.CurrentCulture);
        }
    }
}
